<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" th:with="title='新增用户',active='settings'">
<header th:replace="/header::headerFragment(${title},${active})"></header>
<link th:href="@{/admin/plugins/toggles/toggles.css}" rel="stylesheet"/>
<body class="fixed-left">
<div id="wrapper">
    <div th:replace="/header::header-body"></div>
    <div class="content-page">
        <div class="content">
            <div class="container">
                <div class="row">
                    <div class="col-sm-12">
                        <h4 class="page-title">新增用户</h4>
                    </div>
                    <div class="col-md-6">
                        <div class="panel panel-color panel-primary">
                            <div class="panel-heading">
                                <h3 class="panel-title">信息设置</h3>
                            </div>
                            <div class="panel-body">
                                <form class="form-horizontal" role="form" id="global-form">
                                    <div class="form-group">
                                        <label class="col-md-3 control-label">账号</label>
                                        <div class="col-md-9">
                                            <input type="text" class="form-control" name="account" placeholder="账号"
                                                   required="required" aria-required="true"/>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-md-3 control-label">密码</label>
                                        <div class="col-md-9">
                                            <input type="number" class="form-control" name="password" placeholder="密码"
                                                   required="required" aria-required="true"/>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-md-3 control-label">姓名</label>
                                        <div class="col-md-9">
                                            <input type="text" class="form-control" name="name" placeholder="姓名"
                                                   required="required" aria-required="true"/>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-md-3 control-label">年龄</label>
                                        <div class="col-md-9">
                                            <input type="number" class="form-control" name="age" placeholder="年龄"
                                                    required="required" aria-required="true"/>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-md-3 control-label">性别</label>
                                        <div class="col-md-9">
                                            <input type="number" class="form-control" name="gender" placeholder="性别"
                                                    required="required" aria-required="true"/>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-md-3 control-label">地址</label>
                                        <div class="col-md-9">
                                            <input type="text" class="form-control" name="addr" placeholder="地址"
                                                    required="required" aria-required="true"/>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-md-3 control-label">手机</label>
                                        <div class="col-md-9">
                                            <input type="number" class="form-control" name="phone" placeholder="手机"
                                                    required="required" aria-required="true"/>
                                        </div>
                                    </div>



                                    <input type="hidden" name="allow_install" id="allow_install"/>
                                    <div class="clearfix pull-right">
                                        <button type="button" class="btn btn-primary waves-effect waves-light" onclick="saveSetting()">
                                            添加
                                        </button>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
                <div th:replace="/footer :: footer-content"></div>
            </div>
        </div>
    </div>
</div>
<div th:replace="/footer :: footer"></div>
<script src="//cdn.bootcss.com/jquery-toggles/2.0.4/toggles.min.js"></script>
<script type="text/javascript">
    /*<![CDATA[*/
    var tale = new $.tale();

    /**
     * 保存全局设置
     */
    function saveSetting() {
        var param = $('#global-form').serialize();
        tale.post({
            url : '/admin/addUser',
            data: param,
            success: function (result) {
                if(result && result.success){
                    tale.alertOk('新增用户成功');
                } else {
                    tale.alertError(result.msg || '新增用户失败');
                }
            }
        });
    }



    $('.allow-1').toggles({
        on: true,
        text: {
            on: '开启',
            off: '关闭'
        }
    });
    $('.allow-0').toggles({
        off: true,
        text: {
            on: '开启',
            off: '关闭'
        }
    });
    /*]]>*/
</script>
</body>
</html>